home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15509 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: solon.com!not-for-mail
  2. From: Mike Mitchell <72724.2067@CompuServe.COM>
  3. Newsgroups: comp.lang.c,comp.lang.c.moderated
  4. Subject: 8 Queens prog help
  5. Date: 19 Apr 1996 09:28:29 -0500
  6. Organization: CompuServe, Inc. (1-800-689-0736)
  7. Sender: clc@solutions.solon.com
  8. Approved: clc@solutions.solon.com
  9. Message-ID: <4l87ud$73u@solutions.solon.com>
  10. NNTP-Posting-Host: solutions.solon.com
  11.  
  12. Hi All!
  13.  
  14. Need some C help this week.  I'm currently working on a program 
  15. called "Eight Queens".  Basically, I have to place 8 queen chess 
  16. pieces on an 8x8 chess board without them checking one another.  
  17. The instructer wants us to use a "backtracking algorithm" (i.e. a 
  18. tree structure) to accomplish this.  My thoughts thus far are to 
  19. place my first queen randomly and mark that space with a 'Q' 
  20. character and then mark off all the squares in its legal paths 
  21. (all adjacent squares vertical, horizontal, and diagonal to the 
  22. ends of the board) with an 'X' character.  Board is initialized 
  23. to Nulls.
  24.  
  25. When the next queen piece is placed I will check to see if 
  26. another queen is in one of its paths.  If there isn't I will 
  27. place the piece and mark off its paths otherwise I will return 
  28. the square to NULL and move to the next NULL square.
  29.  
  30. Am I approaching this the right way or should I be handling this 
  31. another way?  Can someone explain how a tree structure 
  32. accomplishes this?
  33.  
  34. We did a similar problem in class using the knight piece and its 
  35. legal moves.  Well, needless to say the number of legal moves a 
  36. queen can make, make this problem a little more difficult. 
  37.